import dayjs from "dayjs";

const dateFormat = (date, format) =>{
  return dayjs(date).format(format)
}

const timeToSeconds = (timeStamp) =>{
  let s = '';
  let hour = timeStamp.split(':')[0];
  let min = timeStamp.split(':')[1];
  let sec = timeStamp.split(':')[2];
  s = Number(hour * 3600) + Number(min * 60) + Number(sec);
  let Sec = Math.round(s * 100) / 100;
  return Sec;
}

const getAge = (birthday) =>{
  const currentDate = new Date();
  const date = new Date(birthday);
  const ageInMilliseconds = currentDate - date;
  return Math.floor(ageInMilliseconds / (1000 * 60 * 60 * 24 * 365.25));
}

export {
	timeToSeconds,
	getAge,
	dateFormat
}